import java.sql.SQLException;

import javax.jws.WebService;

@WebService(targetNamespace="http://localhost:63081/expectedEarnings")
public class ExpectedEarningsService {

	public boolean calcExpectedEarnings(String buildingCosts, String expectedEarnings, String projectID)
	{
		
		DAO dao = new DAO();
		
		boolean buy = false;
		
		double expProfit = 0;
		
		double earnings = Double.parseDouble(expectedEarnings);
		double bCosts = Double.parseDouble(buildingCosts);

		Project p = ProjectContainer.getInstance().getProject(projectID);
		p.setPrice(bCosts);
		p.setExpectedEarning(earnings);
		
		double diff1 = earnings-bCosts;

		double sumCosts = 0.0;
		try {
			sumCosts = dao.getMaterialCosts(projectID);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		expProfit = diff1 - sumCosts;
		
		if(expProfit>0){
			buy = true;
		}

		return buy;
	}
}
